<cfsetting enablecfoutputonly="true">
<!--- Make sure all content to be outputed is wrapped in <cfoutput></cfoutput> tags. --->
<cfswitch expression="#thisTag.executionMode#">
	<cfcase value="start">
		<cfparam name="attributes.id" default="">
		<cfparam name="attributes.records" default="">
		<cfparam name="attributes.pageNum" default="">
		<cfparam name="attributes.pageSize" default="">
		<cfparam name="attributes.addToRoute" default="true">
		<cfparam name="attributes.baseRoute" default="">
		<cfparam name="attributes.outputVariable" default="">
		<cfif StructKeyExists(caller,'root')>
			<cfset root = caller.root>
		<cfelse>
			<cfset root = caller>
		</cfif>
		<cfif NOT thisTag.hasEndTag>
			<cfthrow detail="End tag required" message="All coop tags require an end tag." errorcode="sos.tag.attributes">
		</cfif>
		<cfif attributes.id EQ ''>
			<cfthrow detail="Missing required attribute: 'id'" message="'id' attribute is required">
		</cfif>
		<cfscript>
		standardattributes = 'id,records,pageNum,pageSize'; // internally handled attributes
		attributes = root.coop.mergeattributes(attributes,root);
		attributeList = root.coop.createAttributeList(attributes,standardAttributes,root);
	
	</cfscript>
	</cfcase>
	<cfcase value="end">
		<!--- Head Content --->
		<!--- This is where you include any content that will be included in the head of your document --->
		<cfsaveContent variable="myJSScriptBlock">
			<!--- Include your javascript here and make sure it is wrapped with the following code: <cfoutput><script></script></cfoutput> --->
		</cfsaveContent>
		<cfsaveContent variable="myCSSBlock">
			<!--- Include your CSS here and make sure it is wrapped with the following code: <cfoutput><style></style></cfoutput> --->
		</cfsaveContent>
		<!--- 
		<cfscript>
		pagerString = '';
		recordCount = attributes.records;
		pagesPossible = recordCount / attributes.pageSize;
		if (listLen(pagesPossible,'.') GT 1) {
			pagesPossible = ceiling(pagesPossible);
		}
		if (attributes.pageSize LTE recordCount) {
			if (attributes.pageNum * attributes.pageSize LTE recordCount) {
				start = attributes.pageNum * attributes.pageSize - attributes.pageSize + 1;
				recordCount = attributes.pageNum * attributes.pageSize;
			} else {
				start = recordCount - (attributes.pageNum * attributes.pageSize - recordCount) + 2;
			}
		}
		if (attributes.pageNum EQ 1) {
			pages = min(pagesPossible,10);
			startPage = 1;
		} else {
			pages = min(pagesPossible,max(attributes.pageNum + 5,10));
			startPage = max(1,attributes.pageNum - 5);
		}
		if (attributes.PageNum NEQ 1) {
			pagerString = pagerString & '<a href="?_#attributes.id#_page=1&_#attributes.id#_pageStart=1">&lt;&lt;&nbsp;</a>&nbsp;';
			pagerstring = pagerString & '<a href="?_#attributes.id#_page=#attributes.pageNum -1#&_#attributes.id#_pageStart=#attributes.pageSize * (attributes.pageNum - 1) - attributes.pageSize + 1#">&lt;</a>&nbsp;';
		}
		for (iPage = startPage; iPage LTE pages; iPage = iPage + 1) {
			if (iPage EQ attributes.pageNum) {
				pagerString = pagerString & '<span id="list_#attributes.id#_pager">|&nbsp;#attributes.pageNum#&nbsp;|</span>';
			} else {
				pagerString = pagerString & '<a href="?_#attributes.id#_page=#iPage#&_#attributes.id#_pageStart=#attributes.pageSize * iPage - attributes.pageSize + 1#">&nbsp;#iPage#&nbsp;</a>';
			}
		}
		if (attributes.pageNum LT pagesPossible) {
			pagerString = pagerString & '<a href="?_#attributes.id#_page=#attributes.pageNum + 1#&_#attributes.id#_pageStart=#attributes.pageSize * attributes.pageNum - attributes.pageSize + 1#">&nbsp;&gt;</a>';
			pagerString = pagerString & '<a href="?_#attributes.id#_page=#pagesPossible#&_#attributes.id#_pageStart=#attributes.pageSize * pagesPossible - attributes.pageSize + 1#">&nbsp;&gt;&gt;</a>';
		}
		</cfscript> --->
		<cfset attributes.sosContent = root.coop.sosContent>
		<cfinvoke 
			component="#root.coop.get_shareClassPath()#objects.coop.pager"
			argumentcollection="#attributes#"
			returnvariable="pagerString"
			method="init">
		<cfset pagerString = pagerString.getPager()>
		<cfif len(attributes.outputVariable)>
			<cfset root[attributes.outputVariable] = pagerString>
		<cfelse>
			<cfoutput>#pagerString#</cfoutput>
		</cfif>
	</cfcase>
</cfswitch>
<cfsetting enablecfoutputonly="false">